﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_City_ManageCity : System.Web.UI.Page
{
    public int CID
    {
        get { return Convert.ToInt32(ViewState["_CID"]); }
        set { ViewState["_CID"] = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetDrpDownValue();
            CID = DongDong.Common.Misc.GetQueryStringAsInt("CID");
            if (CID != 0)
            {
                drpShengC.SelectedValue = CID.ToString();
                drpAddSheng.SelectedValue = CID.ToString();
            }
        }
    }
    public void PopulateCity()
    {
        //Lv_Shi.DataSource = City.GetAllByCondition(DongDong.Common.Misc.ConvertToInt(drpShengC.SelectedValue), txtName.Text);
        //Lv_Shi.DataBind();
    }
    public void GetDrpDownValue()
    {
        //drpShengC.DataSource = Provience.GetAll();
        //drpShengC.DataValueField = "ID";
        //drpShengC.DataTextField = "Name";
        //drpShengC.DataBind();
        //drpShengC.Items.Insert(0, new ListItem("请选择", "0"));

        //drpAddSheng.DataSource = Provience.GetAll();
        //drpAddSheng.DataValueField = "ID";
        //drpAddSheng.DataTextField = "Name";
        //drpAddSheng.DataBind();
        //drpAddSheng.Items.Insert(0, new ListItem("请选择", "0"));

    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        //City objCity = new City();
        //objCity.Name = txtShi.Text.Trim();
        //objCity.ProvienceID = DongDong.Common.Misc.ConvertToInt(drpAddSheng.SelectedValue);
        //objCity.Add();
    }
    protected void btn_search_Click_Click(object sender, EventArgs e)
    {
        PopulateCity();
    }
    protected void Lv_Shi_ItemCanceling(object sender, ListViewCancelEventArgs e)
    {
        Lv_Shi.EditIndex = -1;
        PopulateCity();
    }
    protected void Lv_Shi_ItemDeleting(object sender, ListViewDeleteEventArgs e)
    {
        //City.Delete(DongDong.Common.Misc.ConvertToInt(Lv_Shi.DataKeys[e.ItemIndex].Value));
        //PopulateCity();
    }
    protected void Lv_Shi_ItemUpdating(object sender, ListViewUpdateEventArgs e)
    {
        //int ShiID = DongDong.Common.Misc.ConvertToInt(Lv_Shi.DataKeys[e.ItemIndex].Value);
        //City objType = City.Get(ShiID);
        //var item = Lv_Shi.Items[e.ItemIndex];
        //TextBox txtEditTitle = (TextBox)item.FindControl("txtEditTitle");
        //objType.Name = txtEditTitle.Text;

        //objType.Update();
        //Lv_Shi.EditIndex = -1;
        //PopulateCity();
    }
    protected void Lv_Shi_ItemEditing(object sender, ListViewEditEventArgs e)
    {
        Lv_Shi.EditIndex = e.NewEditIndex;
        PopulateCity();
    }
    protected void Lv_Shi_PagePropertiesChanged(object sender, EventArgs e)
    {
        PopulateCity();
    }
    protected void Pager_PreRender(object sender, EventArgs e)
    {
        if (Lv_Shi.Items.Count == 0)
            PopulateCity();
    }

    public string ReturnProName(object ProID)
    {
        string ProName = "暂无信息";
        //Provience objPro = Provience.Get(DongDong.Common.Misc.ConvertToInt(ProID));
        //if (objPro != null)
        //{
        //    ProName = objPro.Name;
        //}
        return ProName;
    }
}